var FrauenVsRefugees = {};

FrauenVsRefugees.Boot = function(t) {
  this.preload = function() {
      t.load.image("game-logo", "assets/images/game-logo.png"),
      t.load.spritesheet("progressBar", "assets/images/progressBar.png", 80, 16)
  };
  this.create = function() {
      t.canvas.className = "frauen-game"
      this.scale.maxWidth = 99999
      this.scale.maxHeight = 99999
      t.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL
      t.scale.fullScreenScaleMode = Phaser.ScaleManager.NO_SCALE
      t.scale.setShowAll(!0)
      t.scale.refresh()
      t.scale.pageAlignHorizontally = !0
      t.scale.pageAlignVertically = !0
      t.state.start("Preload")
  }
};

FrauenVsRefugees.Preload = function(t) {
    this.preload = function() {
        t.load.image("pixel", "assets/images/pixel.png"),
        t.load.onFileComplete.add(this.loadProgress, this);
        var e = t.add.sprite(t.world.centerX, t.world.centerY, "game-logo");
        e.anchor.set(.5, .5),
        this.loadingText = t.add.text(t.world.centerX, t.world.centerY + e.height / 2 + 20, "LOADING...", {
            font: "16px Arial",
            fill: "#ffffff",
            align: "center"
        }),
        this.loadingText.anchor.set(.5, .5),
        t.load.spritesheet("street", "assets/images/street.png", 193, 193),
        this.game.load.atlas("frau", "assets/images/anim/wonderwoman.png", "assets/images/anim/wonderwoman.json"),
        this.game.load.atlas("enemyAzill", "assets/images/anim/longmoan.png", "assets/images/anim/longmoan.json"),
        this.game.load.atlas("enemyAkarab", "assets/images/anim/baraka.png", "assets/images/anim/baraka.json"),
        t.load.atlas("police", "assets/images/anim/police.png", "assets/images/anim/police.json"),
        t.load.atlas("sonya", "assets/images/anim/sonya.png", "assets/images/anim/sonya.json"),
        t.load.spritesheet("progressBar", "assets/images/progressBar.png", 80, 16),
        t.load.spritesheet("arrow-hauptbahnhof", "assets/images/arrow-hauptbahnhof.png", 100, 40),
        t.load.spritesheet("bigguard", "assets/images/anim/bigguard.png", 94, 100),
        t.load.image("tyris", "assets/images/tyris.png"),
        t.load.image("frame", "assets/images/frame.png"),
        t.load.spritesheet("faces", "assets/images/faces.png", 30, 30),
        t.load.spritesheet("social", "assets/images/social.png", 64, 64),
        t.load.bitmapFont("fixedsys", "assets/fonts/fixedsys_0.png", "assets/fonts/fixedsys.fnt"),
        t.load.image("intro", "assets/images/intro.png"),
        t.load.image("shadow", "assets/images/shadow.png"),
        t.load.image("arrow-back", "assets/images/arrow-back.png"),
        t.load.script("filmfilter", "libs/filters/FilmFilter.js"),
        t.load.script("sepia", "libs/filters/pixi/SepiaFilter.js"),
        t.load.script("pixelate", "libs/filters/pixi/PixelateFilter.js"),
        t.load.audio("track-intro", ["assets/sounds/intro.mp3", "assets/sounds/intro.ogg"]),
        t.load.audio("track-win", ["assets/sounds/solstice.mp3", "assets/sounds/solstice.ogg"]),
        t.load.audio("track-game", ["assets/sounds/gameplay-track1.mp3", "assets/sounds/gameplay-track1.ogg"]),
        t.load.audio("track-loose", ["assets/sounds/loose-track.mp3", "assets/sounds/loose-track.ogg"]),
        t.load.audio("frau-jump", ["assets/sounds/frau-yeah.mp3", "assets/sounds/frau-yeah.ogg"]),
        t.load.audio("frau-fall", ["assets/sounds/woman-fall.mp3", "assets/sounds/woman-fall.mp3"]),
        t.load.audio("man-fall", ["assets/sounds/man-fall.mp3", "assets/sounds/man-fall.mp3"]),
        t.load.audio("excelent", ["assets/sounds/excelent.mp3", "assets/sounds/excelent.mp3"]),
        t.load.audio("man-punch", ["assets/sounds/man-punch.mp3", "assets/sounds/man-punch.ogg"]),
        t.load.audio("man-hit", ["assets/sounds/man-hit.mp3", "assets/sounds/man-hit.ogg"]),
        t.load.audio("woman-punch", ["assets/sounds/woman-punch.mp3", "assets/sounds/woman-punch.mp3"]),
        t.load.audio("man-kick-hit", ["assets/sounds/man-kick-hit.mp3", "assets/sounds/man-kick-hit.mp3"]),
        t.load.audio("test", ["assets/sounds/test.mp3", "assets/sounds/test.mp3"]),
        t.load.spritesheet("controller-arrows", "assets/images/controller-arrows.png", 100, 100),
        t.load.spritesheet("controller-buttons", "assets/images/controller-buttons.png", 70, 72)
    }
    ,
    this.loadProgress = function(t, e, i, a) {
        this.loadingText.alpha = a % 2 ? !0 : !1
    }
    ,
    this.create = function() {
        t.state.start("Intro")
    }
};

FrauenVsRefugees.Intro = function(t) {
    this.create = function() {
       
        this.introComplete = !1,
        this.beginTransition = !1,
        this.beginGameMouseClicked = !1,
        this.viewWindow = FrauenVsRefugees.createViewWindow(),
        t.add.existing(this.viewWindow),
        this.sound = t.add.audio("track-intro", FrauenVsRefugees.MUSIC_VOLUME, !0),
        this.sound.play(),
        this.group = t.add.group(),
        this.groupFont = t.add.group(),
        this.viewWindow.addChild(this.group),
        this.viewWindow.addChild(this.groupFont),
        this.viewWindow.mask.inputEnabled = !0,
        this.viewWindow.mask.events.onInputUp.add(this.beginGameFromClick, this),
        this.intro = t.add.sprite(0, 0, "intro");
        var e = FrauenVsRefugees.VIEW_WIDTH / this.intro.width;

        this.intro.scale.set(e, e),
        this.group.addChild(this.intro);
        this.frau = t.add.sprite(0, 0, "frau"),
        this.frau.anchor.set(.5, 1),
        
        this.frau.introAnimation = this.frau.animations.add("intro", Phaser.Animation.generateFrameNames("slice", 14, 15, ".png", 2), 10, !0),
        this.frau.introAnimation.play();return ;
        this.frau.x = FrauenVsRefugees.VIEW_CENTER_X,
        this.frau.y = this.intro.height - 60,
        this.frau.scale.set(.7, .7),
        this.group.addChild(this.frau),
        this.groupFont.fixedToCamera = !0,
        this.whereLabel = t.add.bitmapText(10, 10, "fixedsys", "", 22),
        this.groupFont.addChild(this.whereLabel);
        var i = new TypeWriter(this.whereLabel,"WHERE: _",50);
        i.onComplete.add(this.whereLabelComplete, this);
        var a = t.add.image(t.width - 210, t.height - 80, "social", 0);
        a.inputEnabled = !0,
        a.events.onInputUp.add(this.shareFacebook, this);
        var s = t.add.image(t.width - 140, t.height - 80, "social", 1);
        s.inputEnabled = !0,
        s.events.onInputUp.add(this.shareTwitter, this);
        var n = t.add.image(t.width - 70, t.height - 80, "social", 2);
        n.inputEnabled = !0,
        n.events.onInputUp.add(this.shareGoogle, this);
        var o = t.add.sprite(0, 0, "game-logo");
        o.scale.set(.4, .4),
        o.anchor.set(.5, .5),
        o.fixedToCamera = !0,
        o.cameraOffset.set(o.width / 2 + 10, o.height / 2 + 10);
        var r = t.add.sprite(0, 0, "social", 3);
        r.inputEnabled = !0,
        r.events.onInputUp.add(this.showSettings, this),
        r.fixedToCamera = !0,
        r.cameraOffset.set(16, t.height - 80),
        this.showSettingsAfterTransition = !1
    }
    ,
    this.shareFacebook = function() {
        openURLInPopup("http://www.facebook.com/sharer.php?u=http://12brols.com/3brols/frauen-vs-refugees/", 600, 400)
    }
    ,
    this.shareTwitter = function() {
        openURLInPopup("http://twitter.com/home?status=http://12brols.com/3brols/frauen-vs-refugees/", 600, 400)
    }
    ,
    this.shareGoogle = function() {
        openURLInPopup("https://plus.google.com/share?url=http://12brols.com/3brols/frauen-vs-refugees/", 600, 400)
    }
    ,
    this.whereLabelComplete = function() {
        this.whereLabel.hasDashAtTheEnd = !1;
        var e = t.time.events.repeat(250, 8, this.whereLabelBlink, this);
        e.timer.onComplete.addOnce(this.whereValueWrite, this)
    }
    ,
    this.whereLabelBlink = function() {
        this.whereLabel.text = 1 == this.whereLabel.hasDashAtTheEnd ? "WHERE:" : "WHERE: _",
        this.whereLabel.hasDashAtTheEnd = !this.whereLabel.hasDashAtTheEnd
    }
    ,
    this.whereValueWrite = function() {
        this.whereLabel.text = "WHERE:",
        this.whereValue = t.add.bitmapText(this.whereLabel.width + 20, 10, "fixedsys", "", 22),
        this.groupFont.addChild(this.whereValue),
        this.whereValue.tint = 16711680;
        var e = new TypeWriter(this.whereValue,"Köln, Germany ",50);
        e.onComplete.add(this.whereValueComplete, this)
    }
    ,
    this.whereValueComplete = function() {
        this.whenLabel = t.add.bitmapText(10, 30, "fixedsys", "", 22),
        this.groupFont.addChild(this.whenLabel);
        var e = new TypeWriter(this.whenLabel,"WHEN: _",50);
        e.onComplete.add(this.whenLabelComplete, this)
    }
    ,
    this.whenLabelComplete = function() {
        this.whenLabel.hasDashAtTheEnd = !1;
        var e = t.time.events.repeat(250, 8, this.whenLabelBlink, this);
        e.timer.onComplete.addOnce(this.whenValueWrite, this)
    }
    ,
    this.whenLabelBlink = function() {
        this.whenLabel.text = 1 == this.whenLabel.hasDashAtTheEnd ? "WHEN:" : "WHEN: _",
        this.whenLabel.hasDashAtTheEnd = !this.whenLabel.hasDashAtTheEnd
    }
    ,
    this.whenValueWrite = function() {
        this.whenLabel.text = "WHEN:",
        this.whenValue = t.add.bitmapText(this.whereLabel.width + 20, 30, "fixedsys", "", 22),
        this.groupFont.addChild(this.whenValue),
        this.whenValue.tint = 16711680;
        new TypeWriter(this.whenValue,"01.01.2016 00:00:00:000 ",50)
    }
    ,
    this.showIntroText = function() {
        if (this.introText = t.add.bitmapText(10, 130, "fixedsys", "", 16),
        this.groupFont.addChild(this.introText),
        FrauenVsRefugees.TOUCH) {
            new TypeWriter(this.introText,"The Frau Needs Your Help To Get To The Hauptbahnhof..\nUse Arrow Keys To Move, X/C Keys To Fight. \nTouch Here To Start",25)
        } else {
            new TypeWriter(this.introText,"The Frau Needs Your Help To Get To The Hauptbahnhof..\nUse Arrow Keys To Move, X/C Keys To Fight. \nPress SPACE To Start",25)
        }
    }
    ,
    this.showSettings = function() {
        this.beginGameMouseClicked = !0,
        this.showSettingsAfterTransition = !0
    }
    ,
    this.startGame = function() {
        this.sound.destroy(),
        t.state.start(1 == this.showSettingsAfterTransition ? "Settings" : "Game")
    }
    ,
    this.beginGameFromClick = function() {
        FrauenVsRefugees.TOUCH && (this.beginGameMouseClicked = !0)
    }
    ,
    this.update = function() {
        if (1 != this.beginTransition)
            if (t.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR) || 1 == this.beginGameMouseClicked) {
                if (this.sound.fadeOut(),
                this.beginTransition = !0,
                FrauenVsRefugees.GFX) {
                    var e = new PIXI.PixelateFilter;
                    t.world.filters = [e];
                    var i = t.add.tween(e.size).to({
                        x: 200,
                        y: 200
                    }, 500, Phaser.Easing.Exponential.In, !0)
                }
                var a = this.game.add.graphics(0, 0);
                a.beginFill(0),
                a.lineStyle(1, 0, 1),
                a.drawRect(0, 0, this.game.width, this.game.height),
                a.endFill(),
                a.fixedToCamera = !0,
                a.alpha = 0;
                var i = t.add.tween(a).to({
                    alpha: 1
                }, 1e3, "Linear", !0, 400);
                i.onComplete.add(this.startGame, this)
            } else
                this.group.y > -this.intro.height + FrauenVsRefugees.VIEW_HEIGHT + 5 ? this.group.y -= 1 : 0 == this.introComplete && (this.introComplete = !0,
                this.showIntroText())
    }
}